home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 12921 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.1 KB  |  41 lines

  1. Path: castle.nando.net!news
  2. From: actuary@nando.net  (Bill McCarthy)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Storing C Functions In An Array?
  5. Date: 3 Apr 1996 15:32:52 GMT
  6. Organization: Nando.net Public Access
  7. Message-ID: <4ju5n4$pr7@castle.nando.net>
  8. References: <4jc1u7$5e9@infa.central.susx.ac.uk>
  9. Reply-To: actuary@nando.net (Bill McCarthy)
  10. NNTP-Posting-Host: grail1216.nando.net
  11. X-Newsreader: IBM NewsReader/2 v1.2
  12.  
  13. In <4jc1u7$5e9@infa.central.susx.ac.uk>,
  14. tepd6@central.susx.ac.uk (George Rattray) writes:
  15.  
  16. >Can someone help me, I'm trying to store functions in an array at
  17. >compile time. The following functions are defined as
  18. >
  19. >    struct complex func(struct complex, CHNL);
  20. >
  21. >I want to store them in an array ch[N];
  22. >
  23. >Therefor using the function with an index as 
  24. >
  25. >    ret = ch[0](x,chnl);
  26.  
  27. struct complex { int a; };  /* for test compile */
  28. typedef int CHNL;           /* for test compile */
  29.  
  30. struct complex funca(struct complex, CHNL);
  31. struct complex funcb(struct complex, CHNL);
  32.  
  33. typedef struct complex FUNC( struct complex, CHNL );
  34.  
  35. FUNC *ch[] = {funca, funcb};
  36.  
  37. Bill McCarthy
  38. actuary@nando.net
  39. Wendell, NC  USA
  40.  
  41.